<?php


abstract class BaseTabCitas extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id_cita;


	
	protected $cedula;


	
	protected $nacionalidad;


	
	protected $fecha_cita;


	
	protected $cf_horario;


	
	protected $aceptada;


	
	protected $medio_reservacion;


	
	protected $estatus;


	
	protected $fecha_registro;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getIdCita()
	{

		return $this->id_cita;
	}

	
	public function getCedula()
	{

		return $this->cedula;
	}

	
	public function getNacionalidad()
	{

		return $this->nacionalidad;
	}

	
	public function getFechaCita($format = 'Y-m-d')
	{

		if ($this->fecha_cita === null || $this->fecha_cita === '') {
			return null;
		} elseif (!is_int($this->fecha_cita)) {
						$ts = strtotime($this->fecha_cita);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha_cita] as date/time value: " . var_export($this->fecha_cita, true));
			}
		} else {
			$ts = $this->fecha_cita;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getCfHorario()
	{

		return $this->cf_horario;
	}

	
	public function getAceptada()
	{

		return $this->aceptada;
	}

	
	public function getMedioReservacion()
	{

		return $this->medio_reservacion;
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function getFechaRegistro($format = 'Y-m-d')
	{

		if ($this->fecha_registro === null || $this->fecha_registro === '') {
			return null;
		} elseif (!is_int($this->fecha_registro)) {
						$ts = strtotime($this->fecha_registro);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha_registro] as date/time value: " . var_export($this->fecha_registro, true));
			}
		} else {
			$ts = $this->fecha_registro;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setIdCita($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->id_cita !== $v) {
			$this->id_cita = $v;
			$this->modifiedColumns[] = TabCitasPeer::ID_CITA;
		}

	} 
	
	public function setCedula($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cedula !== $v) {
			$this->cedula = $v;
			$this->modifiedColumns[] = TabCitasPeer::CEDULA;
		}

	} 
	
	public function setNacionalidad($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nacionalidad !== $v) {
			$this->nacionalidad = $v;
			$this->modifiedColumns[] = TabCitasPeer::NACIONALIDAD;
		}

	} 
	
	public function setFechaCita($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha_cita] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha_cita !== $ts) {
			$this->fecha_cita = $ts;
			$this->modifiedColumns[] = TabCitasPeer::FECHA_CITA;
		}

	} 
	
	public function setCfHorario($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_horario !== $v) {
			$this->cf_horario = $v;
			$this->modifiedColumns[] = TabCitasPeer::CF_HORARIO;
		}

	} 
	
	public function setAceptada($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->aceptada !== $v) {
			$this->aceptada = $v;
			$this->modifiedColumns[] = TabCitasPeer::ACEPTADA;
		}

	} 
	
	public function setMedioReservacion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->medio_reservacion !== $v) {
			$this->medio_reservacion = $v;
			$this->modifiedColumns[] = TabCitasPeer::MEDIO_RESERVACION;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = TabCitasPeer::ESTATUS;
		}

	} 
	
	public function setFechaRegistro($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha_registro] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha_registro !== $ts) {
			$this->fecha_registro = $ts;
			$this->modifiedColumns[] = TabCitasPeer::FECHA_REGISTRO;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id_cita = $rs->getString($startcol + 0);

			$this->cedula = $rs->getString($startcol + 1);

			$this->nacionalidad = $rs->getString($startcol + 2);

			$this->fecha_cita = $rs->getDate($startcol + 3, null);

			$this->cf_horario = $rs->getString($startcol + 4);

			$this->aceptada = $rs->getString($startcol + 5);

			$this->medio_reservacion = $rs->getString($startcol + 6);

			$this->estatus = $rs->getString($startcol + 7);

			$this->fecha_registro = $rs->getDate($startcol + 8, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 9; 
		} catch (Exception $e) {
			throw new PropelException("Error populating TabCitas object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TabCitasPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			TabCitasPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TabCitasPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TabCitasPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setIdCita($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += TabCitasPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = TabCitasPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TabCitasPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getIdCita();
				break;
			case 1:
				return $this->getCedula();
				break;
			case 2:
				return $this->getNacionalidad();
				break;
			case 3:
				return $this->getFechaCita();
				break;
			case 4:
				return $this->getCfHorario();
				break;
			case 5:
				return $this->getAceptada();
				break;
			case 6:
				return $this->getMedioReservacion();
				break;
			case 7:
				return $this->getEstatus();
				break;
			case 8:
				return $this->getFechaRegistro();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TabCitasPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getIdCita(),
			$keys[1] => $this->getCedula(),
			$keys[2] => $this->getNacionalidad(),
			$keys[3] => $this->getFechaCita(),
			$keys[4] => $this->getCfHorario(),
			$keys[5] => $this->getAceptada(),
			$keys[6] => $this->getMedioReservacion(),
			$keys[7] => $this->getEstatus(),
			$keys[8] => $this->getFechaRegistro(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TabCitasPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setIdCita($value);
				break;
			case 1:
				$this->setCedula($value);
				break;
			case 2:
				$this->setNacionalidad($value);
				break;
			case 3:
				$this->setFechaCita($value);
				break;
			case 4:
				$this->setCfHorario($value);
				break;
			case 5:
				$this->setAceptada($value);
				break;
			case 6:
				$this->setMedioReservacion($value);
				break;
			case 7:
				$this->setEstatus($value);
				break;
			case 8:
				$this->setFechaRegistro($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TabCitasPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setIdCita($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCedula($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setNacionalidad($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setFechaCita($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCfHorario($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setAceptada($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setMedioReservacion($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setEstatus($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setFechaRegistro($arr[$keys[8]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(TabCitasPeer::DATABASE_NAME);

		if ($this->isColumnModified(TabCitasPeer::ID_CITA)) $criteria->add(TabCitasPeer::ID_CITA, $this->id_cita);
		if ($this->isColumnModified(TabCitasPeer::CEDULA)) $criteria->add(TabCitasPeer::CEDULA, $this->cedula);
		if ($this->isColumnModified(TabCitasPeer::NACIONALIDAD)) $criteria->add(TabCitasPeer::NACIONALIDAD, $this->nacionalidad);
		if ($this->isColumnModified(TabCitasPeer::FECHA_CITA)) $criteria->add(TabCitasPeer::FECHA_CITA, $this->fecha_cita);
		if ($this->isColumnModified(TabCitasPeer::CF_HORARIO)) $criteria->add(TabCitasPeer::CF_HORARIO, $this->cf_horario);
		if ($this->isColumnModified(TabCitasPeer::ACEPTADA)) $criteria->add(TabCitasPeer::ACEPTADA, $this->aceptada);
		if ($this->isColumnModified(TabCitasPeer::MEDIO_RESERVACION)) $criteria->add(TabCitasPeer::MEDIO_RESERVACION, $this->medio_reservacion);
		if ($this->isColumnModified(TabCitasPeer::ESTATUS)) $criteria->add(TabCitasPeer::ESTATUS, $this->estatus);
		if ($this->isColumnModified(TabCitasPeer::FECHA_REGISTRO)) $criteria->add(TabCitasPeer::FECHA_REGISTRO, $this->fecha_registro);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(TabCitasPeer::DATABASE_NAME);

		$criteria->add(TabCitasPeer::ID_CITA, $this->id_cita);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getIdCita();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setIdCita($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCedula($this->cedula);

		$copyObj->setNacionalidad($this->nacionalidad);

		$copyObj->setFechaCita($this->fecha_cita);

		$copyObj->setCfHorario($this->cf_horario);

		$copyObj->setAceptada($this->aceptada);

		$copyObj->setMedioReservacion($this->medio_reservacion);

		$copyObj->setEstatus($this->estatus);

		$copyObj->setFechaRegistro($this->fecha_registro);


		$copyObj->setNew(true);

		$copyObj->setIdCita(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new TabCitasPeer();
		}
		return self::$peer;
	}

} 